package com.spark.userservice.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.spark.basecommon.entity.user.UmsRole;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.Set;

/**
 * <p>
 * 后台用户角色表 Mapper 接口
 * </p>
 *
 * @author fuqiang
 * @since 2020-09-29
 */
@Mapper
public interface UmsRoleMapper extends BaseMapper<UmsRole> {

    /**
     * 根据用户id查询角色信息
     * @param id
     * @return
     */
    @Select("select r.* " +
            "from ums_admin_role_relation ru " +
            "inner join ums_role r on r.id = ru.role_id " +
            "where ru.admin_id = #{id}")
    Set<UmsRole> findRolesByUserId(Long id);
}
